<div class="wrapper">
    <div>
        <div class="box box-top">
            <!-- /.box-header -->
            <!-- form start -->
            <form id="batteryForm" role="form" action="${base}/admin/battery/save" method="post">
                <input type="hidden" name="id" value="${(battery.id)!}">
                <div class="box-body">
                    <div class="form-group">
                        <label for="departmentId">区域管理</label>
                        <select class="form-control select2" style="width: 100%;" id="departmentId" name="departmentId">
                            <#list departments as department_>
                                <option
                                <#if battery?? && battery.departmentId??>
                                    <#if (department_.id)! == (battery.departmentId)!> selected="selected"</#if>
                                </#if>
                                value="${(department_.id)!}">
                                ${(department_.name)!}
                                </option>
                            </#list>
                        </select>
                    </div>
                        <div class="form-group">
                            <label for="no">Code</label>
                            <input type="text" value="${(battery.no)!}" class="form-control" name="no" id="no">
                        </div>
                        <div class="form-group">
                            <label for="name">Name</label>
                            <input type="text" value="${(battery.name)!}" class="form-control" name="name" id="name">
                        </div>
                        <div class="form-group">
                            <label for="memo">Note</label>
                            <input type="text" value="${(battery.memo)!}" class="form-control" name="memo" id="memo">
                        </div>
                        <div class="form-group">
                            <label for="valid">Valid</label>
                            <select name="valid" id="valid" class="form-control">
                                <option value="true" <#if (battery.valid)!true> selected="selected"</#if>>----Valid----</option>
                                <option value="false" <#if ((battery.valid)!true)==false> selected="selected"</#if>>----Invalid----</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="valid">Status</label>
                            <select name="status" id="status" class="form-control">
                                <option value="0" <#if (battery.status!0)==0> selected="selected"</#if>>----空闲中----</option>
                                <option value="1" <#if (battery.status!0)==1> selected="selected"</#if>>----订单中----</option>
                            </select>
                        </div>
                    <div class="box-footer">
                        <button type="button" onclick="$('#batteryForm').submit();" class="btn btn-primary">Save
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function() {
        $("#batteryForm").validate({
            submitHandler:function(form){
                submitBattery();
            }
        });
    });
    function submitBattery(){
        HF.ajaxFormSubmit('batteryForm',function(result){
            alert("Save Success");
            document.location.reload();
        },function(e){ alert("Save Failure");});
    }
</script>
